home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-02-07 | 2.0 KB | 78 lines | [TEXT/MPS ] |
- (*
- CTBOpen [activeOrPassive] -- Open the connection, either proactively (activeOrPassive is "active")
- or for listening (activeOrPassive is "passive").
-
- To compile and link this file using Macintosh Programmer's Workshop,
-
- pascal -w CTBOpen.p
- link -m ENTRYPOINT -o HyperCommands -rt XCMD=2755 -sn Main=CTBOpen ∂
- CTBOpen.p.o "{MPW}"Libraries:interface.o "{MPW}"Libraries:Libraries:HyperXLib.o
-
- © Copyright 1990 by Apple Computer, Inc.
-
- Initial coding 2/90 by Harry R. Chesley.
- *)
-
- {$R-}
-
- {$S CTBOpen } { Segment name must be the same as the command name. }
-
- unit DummyUnit;
-
- interface
-
- uses MemTypes, QuickDraw, OSIntf, ToolIntf, CTBUtils, FTIntf, CMIntf, TMIntf, CRMIntf, HyperXCmd;
-
- procedure EntryPoint(paramPtr: XCmdPtr);
-
- implementation
-
- procedure CTBOpen(paramPtr: XCmdPtr); forward;
-
- procedure EntryPoint(paramPtr: XCmdPtr);
-
- begin
- CTBOpen(paramPtr);
- end;
-
- procedure CTBOpen(paramPtr: XCmdPtr);
-
- {$I CTBUtil.inc}
-
- var doActive: boolean;
- sizes: CMBufferSizes;
- status: CMStatFlags;
-
- procedure Fail(errMsg: Str255); { set theResult and quit }
- begin
- paramPtr^.returnValue := PasToZero(paramPtr,errMsg);
- exit(CTBOpen);
- end;
-
- begin
- { Check the parameter count. }
- if paramPtr^.paramCount > 1 then Fail('Invalid parameter count');
-
- { Figure out whether to open actively or passively. }
- if not ParmPresent(1) then doActive := true
- else if (Chr(paramPtr^.params[1]^^) = 'p') or (Chr(paramPtr^.params[1]^^) = 'P') then
- doActive := false
- else doActive := true;
-
- { Make sure the Comm Toolbox is available. }
- CTBReady;
- { And there's a current connection tool. }
- EnsurePresent(connectionTool);
-
- { Check that we don't already have an open or opening connection. }
- FailOSErr(CMStatus(Globals^^.connHand,sizes,status));
- if BAnd(status,cmStatusOpen+cmStatusOpening) = 0 then
- begin
- { Open. }
- if doActive then FailOSErr(CMOpen(Globals^^.connHand,true,nil,-1))
- else FailOSErr(CMListen(Globals^^.connHand,true,nil,-1));
- end;
- end;
-
- end.
-